package com.SmartCare.utils;

import cn.hutool.core.bean.BeanUtil;
import com.SmartCare.common.dto.role.ElderlyDTO;
import com.SmartCare.pojo.role.ElderlyInformation;
import org.springframework.stereotype.Service;

/**
 * 老人自理能力转换
 */
@Service
public class ElderTransToDTO {
    public ElderlyDTO trans(ElderlyInformation elder) {
        if(elder == null){
            return new ElderlyDTO();
        }
        ElderlyDTO dto = new ElderlyDTO();
        BeanUtil.copyProperties(elder, dto, false);
        dto.setSex(elder.getSex() == 1 ? "男" : "女");
        dto.setSelfCareAbility(getSelfCareAbility(elder.getSelfCareAbility()));
        return dto;
    }

    public String getSelfCareAbility(int ability) {
        switch (ability) {
            case 0:
                return "无需依赖";
            case 1:
                return "轻度依赖";
            case 2:
                return "中度依赖";
            case 3:
                return "重度依赖";
            default:
                return "";
        }
    }
}
